﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WebshopPizzaRio.App_Code.BLL;
using System.Web.Security;

namespace WebshopPizzaRio
{
    public partial class Registreren : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            MembershipCreateStatus createStatus;
            MembershipUser newUser = Membership.CreateUser(UserName.Text, Password.Text, Email.Text, Question.Text, Answer.Text, true, out createStatus);
            switch (createStatus)
            {
                case MembershipCreateStatus.Success:
                    CreateAccountResults.Text = "Gefeliciteerd! Uw account is succesvol aangemaakt.";

                    GebruikersBLL gebruikersLogic = new GebruikersBLL();
                    gebruikersLogic.SetData(Voornaam.Text, Achternaam.Text, Adres.Text, Woonplaats.Text, Telefoon.Text);

                    break;
                case MembershipCreateStatus.DuplicateUserName:
                    CreateAccountResults.Text = "Deze gebruikersnaam bestaat al.";
                    break;

                case MembershipCreateStatus.DuplicateEmail:
                    CreateAccountResults.Text = "Dit e-mailadres bestaal al.";
                    break;
                case MembershipCreateStatus.InvalidEmail:
                    CreateAccountResults.Text = "Uw e-mailadres is ongeldig.";
                    break;
                case MembershipCreateStatus.InvalidAnswer:
                    CreateAccountResults.Text = "Uw beveiligingsantwoord is ongeldig.";
                    break;
                case MembershipCreateStatus.InvalidPassword:
                    CreateAccountResults.Text = "Uw wachtwoord moet uit minimaal 5 karakters bestaan.";

                    break;
                default:
                    CreateAccountResults.Text = "Zorg dat alle velden zijn ingevuld!";
                    break;

            }
        }
    }
}